using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DTO;
using BUS;
using DAL;

public partial class SanPham_chitietsanpham : System.Web.UI.Page
{
    public int sogiay = 0;
    public int dem = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadData();
        }
    }

    private void LoadData()
    {
            int id = int.Parse(Request.QueryString["id"].ToString());
            tbSanPham sanPham = tbSanPhamBUS.GetByID(id);
            lit_tensp.Text = sanPham.tensp.ToString();
            img_Image.Src = "~/Photos/Thumb/" + sanPham.hinhchinh;
            a_Images.HRef = "Photos/" + sanPham.hinhchinh;
            lit_giagoc.Text = sanPham.giagoc.ToString();
            lit_mota.Text = sanPham.tinvantat.ToString();
            lit_diemnoibat.Text = sanPham.mota.ToString();
            lit_dacdiem.Text = sanPham.quydinh.ToString();
            lit_thongtinchitiet.Text = sanPham.thongtinchitiet.ToString();
            lit_giaban.Text = sanPham.giaban.ToString();
            lit_chietkhau.Text = sanPham.chietkhau.ToString();
            int sodh = tbHoaDonBUS.CountByID(sanPham.masp);
            lit_dealcon.Text = (sanPham.soluongban - sodh).ToString();
            lit_songuoimua.Text = sodh.ToString();
            hpl_mua.NavigateUrl = "~/SanPham/giohang.aspx?id=" + id.ToString();
            //if (sanPham.tinhtrang == 1 )
            //{
            //    hpl_mua.NavigateUrl = "~/SanPham/giohang.aspx?id=" + id.ToString();
            //}
            //else
            //{
            //    hpl_mua.Visible = false;
            //}
        //DateTime now = DateTime.Now;
        //DateTime enddate = sanPham.ngayhethan;
        //TimeSpan thoigian = enddate - now;
        //sogiay = int.Parse(Math.Floor(thoigian.TotalSeconds)).ToString();
            //btn_Images.CommandArgument = sanPham.masp.ToString();
    }

}
